﻿namespace EFS.RC.Wallboard.Common.Config.Sections.Phones.Profiles.Charts.Limits
{
	public class Limit
	{
		public Limit(System.String keyValue)
		{
			// check
			EFS.Common.Verify.String(keyValue, "keyValue");

			// set default
			this.Max = System.Int32.MaxValue;

			// parse
			System.Int32 max = 0;
			if (System.Int32.TryParse(keyValue, out max))
			{
				this.Max = max;
			}
		}

		public System.Int32 Max { get; private set; }


		/// Get
		public static Limit Get(
			System.Collections.Specialized.NameValueCollection nvc,
			System.String key)
		{
			// get keyValue
			System.String keyValue = EFS.RC.Wallboard.Common.Config.Sections.Functions.GetSectionEntryValue(nvc, key);
			if (!EFS.Common.Verify.String(keyValue))
			{
				return null;
			}

			// ok
			return new Limit(keyValue);
		}
	}

}